package com.example.demo.common.tools;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName HelloSBWebMvcConfigurer
 * @Description: TODO
 * @Author linjiangyi
 * @Date 2020-05-20
 * @Version V1.0
 **/
@Configuration
public class DEMOWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加一个拦截器
        registry.addInterceptor(new RequestIntercept());
    }

    /**
     * 支持跨域请求处理
     * @param registry
     */
    @Override
    public void addCorsMappings (CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowedMethods("*").allowedHeaders("*").allowCredentials(true);
    }

}
